if (!Reflect) var Reflect = {
    toXMLString : function (o, tagName) {
        var rootName = tagName || 'reflect-object';
        var s = '';
        if (o instanceof Array) {
            if (!tagName) s += '<list>';
            for (var i = 0; i < o.length; i ++) {
                s += Reflect.toXMLString (o[i], rootName);
            }
            if (!tagName) s += '</list>';
            return s;
        }
        s = '<' + rootName + '>';
        if (o instanceof String || typeof o == 'string')
            s += '<![CDATA[' + Reflect.__xmlEncode (o) + ']]>';
        else if (o instanceof Number || typeof o == 'number') {
            s += o;
        } else if (o instanceof Date) {
            s += o.formatTime ();
        } else {
            for (var k in o) {
                var v = o [k];
                if (typeof v != 'function') s += Reflect.toXMLString (v, k);
            }
        }
        s += '</' + rootName + '>';
        return s;
    },
    toJson : function (o) {
        if (o instanceof Array)
            return Reflect.arrayToString (o);
        if (o instanceof Date || typeof o == 'date')
            return Reflect.formatDate(o);
        if (o instanceof Number || typeof o == 'number')
            return o;
        if (o instanceof String || typeof o == 'string')
            return "'" + o.replace (/'/g, "\\'") + "'";
        if (o instanceof Boolean || typeof o == 'boolean')
            return o;

        var s = '';
        for (var k in o) {
            var v = o[k];
            if (s.length > 0) s += ',';
            if (typeof v != 'function') {
				if (/^[a-zA-Z_$][a-zA-Z_$\d]*$/.test (k))
					s += k + ':' + Reflect.toJson(v);
				else
					s += "'" + k + "':" + Reflect.toJson(v);
			}
        }
        return '{' + s + '}';
    },
    arrayToString : function  (a) {
        var s = '';
        for (var i = 0; i < a.length; i ++) {
            if (s.length > 0) s += ',';
            s += Reflect.toJson(a [i]);
        }
        return '[' + s + ']';
    },
    formatDate : function  (a) {
        var year = a.getFullYear ();
        var month = a.getMonth () + 1;
        var date = a.getDate ();

        var s = year + '-';
        if (month < 10) s += '0';
        s += month + '-';
        if (date < 10) s += '0';
        return "'" + s + date + "'";
    },
    __xmlEncode : function  (text) {
        return  text.replace ('&', '&amp;').replace ('<', '&lt;').replace ('>', '&lt;');
    }
};